package com.nbsaas.boot.cms.rest.convert;

import com.nbsaas.boot.cms.data.entity.News;
import com.nbsaas.boot.cms.api.domain.simple.NewsSimple;

import com.nbsaas.boot.rest.api.Converter;

/**
* 新闻-列表对象转换器
*/

public class NewsSimpleConvert implements Converter<NewsSimple, News> {




@Override
public NewsSimple convert(News source) {
    NewsSimple result = new NewsSimple();

                result.setNote(source.getNote());

               try {
                   if(source.getCreator()!=null){
                       result.setCreator(source.getCreator().getId());
                   }
                } catch (Exception ignored) { }

                result.setIntroduce(source.getIntroduce());

                try {
                    if(source.getCreator()!=null){
                        result.setCreatorName(source.getCreator().getName());
                    }
                } catch (Exception ignored) { }


                try {
                    if(source.getNewsCatalog()!=null){
                        result.setNewsCatalogName(source.getNewsCatalog().getName());
                    }
                } catch (Exception ignored) { }


               try {
                   if(source.getNewsCatalog()!=null){
                       result.setNewsCatalog(source.getNewsCatalog().getId());
                   }
                } catch (Exception ignored) { }

                result.setTitle(source.getTitle());
                result.setAddDate(source.getAddDate());
                result.setUrl(source.getUrl());
                result.setViewNum(source.getViewNum());
                result.setVideoUrl(source.getVideoUrl());
                result.setLogo(source.getLogo());
                if(source.getStoreState()!=null){
                    result.setStoreStateName(String.valueOf(source.getStoreState()));
                }
                result.setStoreState(source.getStoreState());
                result.setId(source.getId());
                result.setLastDate(source.getLastDate());


    return result;
}

}